package com.zky.gulimall.product.web;

import com.alibaba.fastjson.JSON;
import com.zky.gulimall.product.service.SkuInfoService;
import com.zky.gulimall.product.vo.SkuItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


/**
 * @Description Item
 * @Author 张开源
 * @Date 2022/11/19 23:57
 * @Version 1.0
 **/
@Controller
@Slf4j
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;


    /**
     * 展示当前sku详情信息
     *
     * @param skuId
     * @return
     */
    @GetMapping({"/{skuId}.html"})
    public String indexPage(@PathVariable("skuId") Long skuId, Model model) {
        SkuItemVo  itemVo=skuInfoService.item(skuId);
        log.info("itemVo:"+itemVo);
        log.info("itemVoStr:"+ JSON.toJSONString(itemVo));
        model.addAttribute("item",itemVo);
        return "item";
    }
}
